﻿using UnityEditor;
using UnityEditor.UI;
using UnityEngine;
using UnityEngine.UI;

namespace UnityEditor.UI
{
	[CustomEditor(typeof(UVImage))]
	public class UVImageEditor : ImageEditor
	{
		private SerializedProperty m_fill;
		private SerializedProperty m_shape;
		private SerializedProperty m_segments;
		private SerializedProperty m_edgeThickness;
		private SerializedProperty m_scale;
		private SerializedProperty m_uvPivot;

			GUIContent txtShapType;
			GUIContent txtFillType;
			GUIContent txtsegments  ;
		protected override void OnEnable()
		{
			base.OnEnable();
			this.m_shape = this.serializedObject.FindProperty("shape");
			this.m_fill = this.serializedObject.FindProperty("fill");
			this.m_segments = this.serializedObject.FindProperty("segments");
			this.m_edgeThickness = this.serializedObject.FindProperty("edge");
			this.m_scale = this.serializedObject.FindProperty("scale");
			this.m_uvPivot = this.serializedObject.FindProperty("uvPivot");
			
			this.txtShapType = EditorGUIUtility.TrTextContent("shape Type");
			this.txtFillType = EditorGUIUtility.TrTextContent("Fill Type");
			this.txtsegments = EditorGUIUtility.TrTextContent("segments");
		}

		public override void OnInspectorGUI()
		{
			base.OnInspectorGUI();
			EditorGUILayout.LabelField("Setting");
			EditorGUILayout.PropertyField(this.m_shape, this.txtShapType);
			if(m_shape.enumValueIndex == (int)UVImage.ShapeMode.Circle)
				EditorGUILayout.PropertyField(this.m_segments,txtsegments );
			
			EditorGUILayout.PropertyField(this.m_fill, this.txtFillType);
			if (m_fill.enumValueIndex == (int)UVImage.FillMode.Edge)
				EditorGUILayout.PropertyField(this.m_edgeThickness);

			EditorGUILayout.PropertyField(this.m_scale);
			EditorGUILayout.PropertyField(this.m_uvPivot);
			this.serializedObject.ApplyModifiedProperties();
		}
	}
}